package com.qf.service.impl;

import com.qf.service.UserService;
import com.qf.dao.UserDao;
import com.qf.pojo.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserServiceImpl implements UserService {
    @Autowired
    UserDao dao;
    @Override
    public User findByUsername(String username) {
        return dao.findByUsername(username);
    }

    @Override
    public boolean register(User user) {
        //已激活
        user.setFlag(1);
        //设置为管理员
        user.setRole(0);
        //添加新用户
        dao.add(user);

        return true;

    }

    @Override
    public User findByUserAndPwd(String username, String password) {
        return dao.findByUserAndPwd(username,password);
    }

    @Override
    public void deleteUser(int id) {
        dao.deleteUser(id);

    }

    @Override
    public List<User> searchUser(String username, String gender) {
       return dao.searchUser(username,gender);

    }

    @Override
    public List<User> getAllNumbers() {
        return dao.getAllNumbers();
    }

    @Override
    public User findUser(int uid) {
        return dao.findUser(uid);
    }
}
